package com.example.zytphone.adapter;

import android.os.Handler;
import android.os.Message;
import android.text.format.DateFormat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.zytphone.R;
import com.example.zytphone.base.BPData;

import java.util.List;

public class RecycleViewAdapter extends RecyclerView.Adapter<RecycleViewAdapter.ViewHolder> {

    private List<BPData> list;

    public RecycleViewAdapter(List<BPData> list) {
        this.list = list;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view=LayoutInflater.from(parent.getContext()).inflate(R.layout.activity_home_item,parent,false);
        ViewHolder viewHolder=new ViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        holder.ssy_bp.setText(String.valueOf(list.get(position).getSsy()));
        holder.szy_bp.setText(String.valueOf(list.get(position).getSzy()));
        holder.tv_time.setText(String.valueOf(list.get(position).getTime()));
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    class ViewHolder extends RecyclerView.ViewHolder{
        TextView ssy_bp,szy_bp,ssy,szy,tv_time;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            ssy_bp=itemView.findViewById(R.id.ssy_bp);
            szy_bp=itemView.findViewById(R.id.szy_bp);
            szy=itemView.findViewById(R.id.szy);
            ssy=itemView.findViewById(R.id.ssy);
            tv_time=itemView.findViewById(R.id.tv_time);
        }
    }
}
